import { get, post, del } from "@/utils/request";
import { type listData, type listParams, type RolelistReturn, type RoleAddParams } from "./type";

// 岗位列表（角色）
export const RoleList = (data: listParams) => {
  return get<listParams, RolelistReturn>("/api/role/list", data);
};

// 获取权限列表
export const getMenuList = () => {
  return get<null, RolelistReturn>("/api/menu/list");
};

// 添加
export const RoleAdd = (data: RoleAddParams) => {
  return post<RoleAddParams, listData>("/api/role/add", data);
};

// 根据id获取单条数据
export const getRoleById = (id: number) => {
  return get<null, listData>(`/api/role/get/${id}`);
};

// 删除
export const RoleDel = (id: number) => {
  return del<number, null>(`/api/role/delete/${id}`);
};

// 批量删除
export const RoleDelAll = (data: number[]) => {
  return post<number[], null>("/api/role/deleteAll", data);
};
